<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>请假信息</title>
    
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/pintuer.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/admin.css">
    <script src="<%=request.getContextPath()%>/js/jquery.js"></script>
    <script src="<%=request.getContextPath()%>/js/pintuer.js"></script>
</head>

<body>
    <form method="post" action="list" id="listform">
        <div class="panel admin-panel">
            <div class="panel-head">
                <strong class="icon-reorder"> 用户列表</strong>
                <a href="" style="float:right; display:none;">添加字段</a>
            </div>
            
            <div class="padding border-bottom">
                <ul class="search" style="padding-left:10px;">
                    <li>
                        <a class="button border-main icon-plus-square-o" href="LeaveServlet?action=adds">
                            填写请假申请
                        </a>
                    </li>
                </ul>
            </div>

            <table class="table table-hover text-center">
                <tr>
                    <th>请假单号</th>
                    <th>学号</th>
                    <th>请假课程</th>
                    <th>请假事由</th>
                    <th>请假天数</th>
                    <th>审批意见</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                
                <c:forEach var="item" items="${requestScope.list}">
                    <tr>
                        <td style="height: 60px;">${item.leaveID}</td>
                        <td>${item.stuNo}</td>
                        <td>${item.courseID}</td>
                        <td>${item.reason}</td>
                        <td>${item.daynum}</td>
                        <td>${item.opinion != null ? item.opinion : "暂无"}</td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status==1}">
                                    <span style="color: #00aa00">同意</span>
                                </c:when>
                                <c:when test="${item.status==2}">
                                    <span style="color: red">不同意</span>
                                </c:when>
                                <c:otherwise>
                                    待审核
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td>
                            <div class="button-group">
                                <c:if test="${item.status!=1}">
                                    <a class="button border-red" onclick="confirmDelete('${item.leaveID}')">
                                        <span class="icon-trash-o"></span> 删除
                                    </a>
                                </c:if>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </form>

    <script type="text/javascript">
        function changeSearch() {
            $("#listform").submit();
        }

        function confirmDelete(leaveID) {
            if (confirm("确定要删除该条记录吗？")) {
                window.location.href = "LeaveServlet?action=delete&leaveID=" + leaveID;
            }
        }
    </script>
</body>
</html>
